<?php
/*
  $Id: specials.php,v 1.31 2003/06/09 22:21:03 hpdl Exp $

 E-Commerce Solutions

  Copyright (c) 2005 www.flash-template-design.com

  Released under the GNU General Public License
*/

//  if ($random_product = tep_random_select("select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s where p.products_status = '1' and p.products_id = s.products_id and pd.products_id = s.products_id and pd.language_id = '" . (int)$languages_id . "' and s.status = '1' order by s.specials_date_added desc limit " . MAX_RANDOM_SELECT_SPECIALS)) {
?>
<!-- specials //-->
          <tr>
            <td>
<?php

   

   if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) {
    $new_products_query = tep_db_query("select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s where p.products_status = '1' and p.products_id = s.products_id and pd.products_id = s.products_id and pd.language_id = '" . (int)$languages_id . "' and s.status = '1' order by s.specials_date_added desc limit " . MAX_RANDOM_SELECT_SPECIALS);
  } //else {
  //  $new_products_query = tep_db_query("select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s where p.products_status = '1' and p.products_id = s.products_id and pd.products_id = s.products_id and pd.language_id = '" . (int)$languages_id . "' and s.status = '1' order by s.specials_date_added desc limit " . MAX_RANDOM_SELECT_SPECIALS);
 // }

 $info_box_contents = array();
    $info_box_contents[] = array('text' => 'Featured Products');

   new contentBoxHeading($info_box_contents);
  $row = 0;
  $col = 0;
  $info_box_contents = array();
  while ($new_products = tep_db_fetch_array($new_products_query)) {
    $new_products['products_name'] = tep_get_products_name($new_products['products_id']);
	
	$sql = 'SELECT `products_description` FROM `products_description` WHERE products_id ='.$new_products['products_id'].' && language_id='.(int)$languages_id;
	$description_query = tep_db_query($sql);
	$description = mysql_fetch_array($description_query, MYSQL_ASSOC);        
	$description['products_description'] = substr($description['products_description'], 0, 65);
	$desc_len = strlen($description['products_description']);
$description['products_description'][$desc_len-1] = '.';
	$description['products_description'][$desc_len-2] = '.';
	$description['products_description'][$desc_len-3] = '.';
		
	/*if  ( ($col == 1 && $row == 0) || ($col == 1 && $row == 2) ){
	$info_box_contents[$row][$col] = array('align' => 'center',
                                           'params' => 'width="21" height="100%" valign="middle"',
                                           'text' => '<table height="90%" width="100%" background="'.DIR_WS_IMAGES .'theme/m_vert.jpg" border="1" cellspacing="0" cellpadding="0" >
  <tr>
    <td><div style="width:21px"></div></td>
  </tr>
</table>');
	}
	elseif (($col == 0 && $row == 1) || ($col == 2 && $row == 1)) {
	$info_box_contents[$row][$col] = array('align' => 'center',
                                           'params' => 'height="21"',
                                           'text' => '<table width="90%" background="'.DIR_WS_IMAGES .'theme/m_horizontal.jpg" border="0" cellspacing="0" cellpadding="0" >
  <tr>
    <td><div style="height:21px"></td>
  </tr>
</table>');
	}
elseif ($col == 1 && $row == 1) {
	$info_box_contents[$row][$col] = array('align' => '',
                                           'params' => '',
                                           'text' => '&nbsp;');
	}
else {	*/
    $info_box_contents[$row][$col] = array('align' => 'center',
                                           'params' => 'width="33%" height="218" style="padding-top:3px;"',
                                           'text' => '<div class="new_prod"><p align="left"><b>'.$new_products['products_name'].'</b><br/>
					<span>'.$description['products_description'].'</span></p><img src="images/points.gif" alt="" width="163" height="1" /><div class="image"><a href="'. tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) .'">'. tep_image(DIR_WS_IMAGES . $new_products['products_image'], $new_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'align="left"') . '</a></div><div class="price"><span style="text-decoration:line-through">'. $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id'])).'</span><br/>
<br/><span style="color:#F00;"> '.$currencies->display_price($new_products['specials_new_products_price'], tep_get_tax_rate($new_products['products_tax_class_id'])).
'</span></div>
<div class="buy">' 
. tep_draw_form('cart_quantity', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=add_product')).'<a href="'.tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']).'"><img src="images/bdetails.gif" alt="" width="67" height="16" border="0" /></a>&nbsp;&nbsp;'.tep_draw_hidden_field('products_id', $new_products['products_id']) . tep_image_submit('add_to_cart.gif', IMAGE_BUTTON_IN_CART) .'</form></div>
					</div>'); 
/*
'<div class="new_prod"><p align="left"><b>'.$new_products['products_name'].'</b><br/>
					<span>'.$description['products_description'].'</span></p><img src="images/points.gif" alt="" width="163" height="1" /><div class="image"><a href="'. tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) .'">'. tep_image(DIR_WS_IMAGES . $new_products['products_image'], $new_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'align="absmiddle"') . '</a></div><div class="price">'. $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id'])).'<br/>
<img src="images/new.gif" alt="" width="44" height="44" />
</div>
<div class="buy"> 
<a href=""><img src="images/bdetails.gif" alt="" width="67" height="16" border="0" /></a>
'. tep_draw_hidden_field('products_id', $new_products['products_id']) . tep_image_submit('add_to_cart.gif', IMAGE_BUTTON_IN_CART) .'
</div>
					</div>'


*/
										   
    $col ++;
    if ($col > 2) {
     break;
    }
	
  }
  new contentBox($info_box_contents, 0);

?>
            </td>
          </tr>
<!-- specials_eof //-->

